package com.framework.yhbapi.controller;

import com.framework.exception.util.RespResult;
import com.framework.service.yhbservice.YhbTransactionService;
import com.framework.yhbEntity.view.CusTranView;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 功能描述: 交易模块Controller
 *
 * @author ck
 * @date 2018/9/3 11:45
 */
@RestController
@Api(value="交易模块",tags={"交易模块"})
@RequestMapping(value = "yhbTransaction")
public class YhbTransactionController {

	@Autowired
	private YhbTransactionService yhbTransactionService;

	/**
	 *  获取交易列表
	 * @param token
	 * @param sn 机具sn
	 */
	@PostMapping("user/queryTransactionList")
	@ApiOperation("获取交易列表")
	@ApiImplicitParams({
			@ApiImplicitParam(name="token",value="登录产生token",dataType="String", paramType = "query" ),
			@ApiImplicitParam(name="sn",value="机具sn",dataType="string", paramType = "query")
	})
	public RespResult queryTransactionList(String token,String sn) {
		List<Map<String, Object>> list = yhbTransactionService.queryTransactionList(token, sn);
		return RespResult.ok().put("list",list);

	}

	/**
	 *  获取商户交易
	 * @param token
	 */
	@PostMapping("user/queryCusTranList")
	@ApiOperation("获取商户交易")
	@ApiImplicitParams({
			@ApiImplicitParam(name="token",value="登录产生token",dataType="String", paramType = "query" ),
			@ApiImplicitParam(name="pageNo",value="页数 从1开始",dataType="integer", paramType = "query" )

	})
	public RespResult queryCusTranList(String token,Integer pageNo) {
		List<CusTranView> list = yhbTransactionService.queryCusTranList(token,pageNo);
		return RespResult.ok().put("list",list);

	}
}
